<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Construct Unit test file | Class</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script type="text/javascript" charset="utf-8">
    var eventResults = {};
    var originalElement = window.Element;
  </script>
  <script src="../../lib/prototype.js" type="text/javascript"></script>
  <script src="../../lib/unittest.js" type="text/javascript"></script>
  <link rel="stylesheet" href="../../test.css" type="text/css" />
  <script type="text/javascript">
/*------------------------------- Begin Test Code ---------------------------*/

/**
 * @projectDescription
 * Construct Javascript Framework :: Building A Better Web
 * 
 * Much of this framework has been adapted from or inspired by the excellent: 
 *   Prototype <http://www.prototypejs.org>, 
 *   jQuery    <http://jquery.com>, and
 *   Mootools  <http://mootools.net/> 
 * frameworks (which are all available under the MIT license). The creators 
 * and contributors of these frameworks rock and without them, Construct 
 * (and the web as we know it) wouldn't exist. Comments, feeback, bugs and 
 * donations (all of which are greatly appreciated) should be directed to the 
 * Construct website: <http://constructjs.org>.
 * 
 * @version 0.1.0.0
 * @author Brent Broome
 * @copyright 2008, Brent Broome
 * @license MIT <http://www.opensource.org/licenses/mit-license.php>
 */

// _C, Element and Event are the only global variables we define (and the 
// latter two only get defined if they're not native in the browser)
var 

/**
 * This is the core Construct object, which happens to also be the familiar _C 
 * function. If you pass it a String, it returns the Element in the document 
 * with the matching id (or null if no such Element exists). If you pass it a 
 * native DOM node, it returns it wrapped in an Element. If you pass it an 
 * Element, it returns it unchanged. If you pass it multiple arguments, it
 * returns an Array of Elements, one for each String, node or Element in the
 * original Array.
 * 
 * @see Element
 * @param {String,Element} element The element id, native DOM node or existing
 *  Element to wrap in an Element and return. If multiple arguements are 
 *  provided, they are all wrapped and returned in an Array.
 * @return {Element} The wrapped Element (or Array of Elements)
 * @since 0.1
 */
_C = function(element) 
{
  var i, elements = [], length = arguments.length; 
   
  if (length > 1) {
    for (i = 0; i < length; i++) 
      elements.push(_C(arguments[i]));
      
    return elements;
  }  
  
  if (typeof element == 'string')
    element = document.getElementById(element);    
    
  return Element.extend(element);
},

/**
 * This object wraps native DOM nodes (those things returned by native
 * functions such as document.getElementById) and provides simple,
 * efficient, cross-browser methods for querying and manipulating them. 
 * @since 0.1
 */
Element = window.Element || {},

/**
 * This object wraps native event objects and provides simple,
 * efficient, cross-browser methods for querying and manipulating them. 
 * @since 0.1
 */
Event = window.Event || {};

  
/**
 * The current version of the framework, formatted as:
 * 'major,minor,revision,build', which are incremented as follows:
 * 
 *   major   : When there are major changes made to the architecture, 
 *             stability or scope of the framework
 *   minor   : When there is a change made to the API of the framework,
 *             such as adding or removing classes or methods, changing
 *             arguments, deprecating existing methods, etc. 
 *   revision: When a new version of the framework is released without
 *             any changes to the API (i.e. bug fix releases).
 *   build   : When ANY change is made to the framework (this is only 
 *             used internally for development and will always be 0
 *             for public releases)
 *             
 * Note: Incrementing any of the values zeros-out the values to its right.
 * @alias _C.Version
 * @since 0.1
 */
_C.Version = '0.1.0.0';

/**
 * An empty function, provided for convenience and clarity
 * @since 0.1
 */
_C.EmptyFn = function() {};

/**
 * The identity function, which returns its argument unchanged
 * @param  {Object} x The object to return
 * @return {Object} The object passed as the argument
 * @since 0.1
 */
_C.IdFn = function(x) { return x; };
  
/**
 * Adds all of the properties in source to destination (overwriting
 * them if they already exist) and returns destination.
 * @param {Object} destination The object to extend.
 * @param {Object} source      The object from which to extend.
 * @return {Object} destination, extended with all the properties in source
 * @since 0.1
 */
_C.extend = function(destination, source) 
{
  for (var property in source) 
    destination[property] = source[property];  
   
  return destination;
};

/*
 * Wrap all other code in a monolithic anonymous function to allow the
 * definition of variables during the initialization of the framework
 * (for simplicity, efficiency and mungeability) without poluting the
 * global namespace.
 */
(function() {  // begin global wrapper
/*
 file: class.js
 dependsOn: core.js
 */

// Add some properties to the core object
_C.extend(_C, 
{
  /**
   * Builds an Array from an iterable (an object with a length property and
   * an indexer, such as NodeList or arguments) or from an object with a
   * toArray method.
   * @alias _C.A
   * @param {Object} object The object to build an Array from
   * @return {Array} The Array containing the elements in the iterable or
   *  object, or an empty Array if conversion wasn't possible.
   * @since 0.1
   */
  A: function(object) 
  {
    if (!object) 
      return [];  
      
    if (object.toArray && (!_C.WebKit || object != '[object NodeList]'))
      return object.toArray();
    
    var length = object.length || 0, results = [];
    
    while (length--) 
      results[length] = object[length];
      
    return results;
  },
  
  /**
   * Adds methods to destination's prototype from source.
   * @alias _C.addMethods
   * @param {Object} destination The object whose prototype should be extended
   * @param {Object} source      The object with the methods to add
   * @param {Object} overwrite   Flags whether to overwrite existing methods in
   *  destination's prototype with those in source
   * @since 0.1
   */
  addMethods: function(destination, source, overwrite) 
  {
    for (var property in source) 
      if ((!(property in destination.prototype) || overwrite) && 
          typeof source[property] == 'function') 
        destination.prototype[property] = source[property];   
  },
  
  /**
   * Flags whether the browser skips iterating over built-in
   * functions such as toString and valueOf
   * @alias $.BuiltInsHidden
   * @since 0.1
   */
  BuiltInsHidden: !('toString' in { toString: 1 }),
  
  /**
   * Returns a shallow clone of the passed object. Note that the type of
   * the passed object will be preserved, as the cloned object will be
   * constructed using the passed object's constructor.
   * @param {Object} object The object to clone
   * @return {Object} A clone of the object
   * @since 0.1
   */
  clone: function(object) 
  {
    var destination = new object.constructor, property;
    
    for (property in object) 
      destination[property] = object[property];  
     
    return destination;
  },

  /**
   * Tests whether the passed object is an instance (or sublcass) of
   * the class provided. Some examples:
   *   isA(x, Object) returns true if x isn't null, undefined or a primitive.
   *   isA(x, Number) returns true if x is a Number or a primitive number.
   *   isA(x, Car)    returns true if x is a Car or any subclass of Car.
   * @alias _C.isA
   * @param  {Object}  object The object to test
   * @param  {Object}  object The class to check against
   * @return {Boolean} True if the object is an instance (or sublcass) of
   *  the class provided, false otherwise.
   * @since 0.1
   */
  isA: function(object, type) 
  {
    if(object == null || type == null)
      return false;
    
    var ctor = object.constructor;
    
    do {
      if(ctor === type)
        return true;
    } while(ctor = ctor.superclass);
    
    return false;
  },

  /**
   * Creates a new class from the definition provided.
   * @alias _C.newClass
   * @param {Object} definition The class definition, which should be an 
   *  object containing the methods for this class as properties, as well as
   *  a reference to the superclass in a property named superclass (should
   *  inheritence be desired). If a superclass is specified and any of the 
   *  methods in the definition already exist in the superclass, they will be 
   *  overwritten and the original method in the superclass can be invoked
   *  by calling $super. The method that should be invoked when constructing
   *  new objects of this class should be provided in a property named
   *  construct, otherwise a default (which does nothing) will be used.
   *  Finally, _C.isA will return true if an object of this class is tested 
   *  against a reference to one of its ancestor classes.
   * @return {Class} The newly created class
   * @see Class#$super
   * @since 0.1
   */
  newClass: function(definition) 
  {
    var theClass = function() { // the constructor
          this.construct.apply(this, arguments); 
        }, 
        superclass   = definition.superclass;      
    
    /**
     * The superclass of this class (or Object if none was provided)
     * @alias Class.superclass
     * @since 0.1
     */
    theClass.superclass  = superclass || Object;
    
    theClass.addMethods = function(methods) {
      var superclass = this.superclass && this.superclass.prototype,
          property, value, method;
  
      if (_C.BuiltInsHidden)
        properties.push("toString", "valueOf");
  
      for (property in methods) {
        value = methods[property];
        if (superclass && typeof value == 'function' &&
            value.argumentNames()[0] == "$super") {
          method = value;
          value = (function(m) {
            return function() { return superclass[m].apply(this, arguments) };
          })(property).wrap(method);
          value.valueOf  = method.valueOf.bindTo(method);
          value.toString = method.toString.bindTo(method);
        }
        this.prototype[property] = value;
      }
  
      return this;
    };
    
    theClass.prototype = superclass ? _C.clone(superclass.prototype) : {};
    theClass.addMethods(definition); 
    theClass.prototype.constructor = theClass;
        
    /**
     * Function called from the constructor of this class whenever
     * an object of this class is created.
     * @alias Class.prototype.construct
     * @param {Object} [args] Zero or more arguments to pass to the
     *  construct method of your class, as appropriate.
     * @return The newly-constructed instance of this class
     * @since 0.1
     */
    if(!definition.construct) 
      theClass.prototype.construct = _C.EmptyFn;        
    
    return theClass;
  },
  
  /*
   * Private object for storing precompiled regular expressions
   */
  _R:
  {
    // Captures function argument names in [1]
    ArgNames: /^[\s\(]*function[^(]*\(([^\)]*)\)/,
    
    // Special characters in regular expressions that need to be escaped
    RExSC   : /([.*+?^=!:${}()|[\]\/\\])/g,
    
    // One or more whitespace characters
    SomeWS  : /\s+/g
  }  
});

_C.extend(Function.prototype, {
  argNames: function() {
    var names = this.toString().match(_C._R.ArgNames)[1]
      .replace(_C._R.SomeWS, '').split(',');
    return names.length == 1 && !names[0] ? [] : names;
  },

  /**
   * Gets a version of this function that will execute in the context
   * of the passed object (that is, the keyword this will refer to the 
   * passed object when the returned function is executed).
   * @param  {Object}   object The object to execute in the context of
   * @return {Function} A version of this function that will be invoked
   *  in the context of the passed object.
   */
  bindTo: function(object) 
  {
    var self = this;
    
    return function() {
      return self.apply(object, arguments);
    }
  },
  
  /**
   * Transforms this function from one that takes an Object of type T
   * as its first argument to one that is a method of type T, which 
   * invokes the original method with itself as the first argument.
   * @alias Function.prototype.methodize
   * @return The methodized function
   * @since 0.1
   */
  methodize: function() 
  {
    var self = this;
    
    return function() {
      return self.apply(null, [this].concat($.A(arguments)));
    };
  },
  
  wrap: function(wrapper) {
    var self = this;
    
    return function() {
      return wrapper.apply(this, [self.bind(this)].concat($A(arguments)));
    }
  }
});

/*<function.js>*/

/**<utils.js>**/

/**<string.js>**/

/**<number.js>**/

/**<enumerable.js>**/

/**<array.js>**/

/**<hash.js>**/

/**<range.js>**/

/**<browsers.js>**/

/**<elementCore.js>**/

/**<elementStyles.js>**/

/**<elementUtils.js>**/

/**<selector.js>**/

/**<form.js>**/

/**<event.js>**/

/**<ajax.js>**/

/**<fx.js>**/

// Ensure the _C function works even if the Element module isn't included
if(!Element.extend) 
  Element.extend = _C.IdFn;   

})(); // end global wrapper

/*-------------------------------- End Test Code ----------------------------*/
/*----------------------------- Begin Test Fixtures -------------------------*/

var _fixtureVersion = '0.1.0.0'

/*------------------------------ End Test Fixtures --------------------------*/
  </script>
  <script src="../classTest.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<h1>Construct Unit test file</h1>
<h2>Core</h2>

<!-- This file is programmatically generated. Do not attempt to modify it. Instead, modify  -->

<!-- Log output start -->
<div id="testlog"></div>
<!-- Log output end -->

<!-- HTML Fixtures start -->
<div id="testNode">22<span id="testChildNode"></span><span></span></div>
<!-- HTML Fixtures end -->
</body>
</html>
<script type="text/javascript" charset="utf-8">
  eventResults.endOfDocument = true;
</script>
